<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../node_modules/vue/dist/vue.global.js"></script>
    <style>
        .on {
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 设置动态属性 -->
        <p v-bind:id="idnum">{{msg}}</p>
        <input type="text" v-bind:value="msg">
        <input type="radio" v-bind:checked="flag">
        <!-- 简写方式  -->
        <!-- <img :src="imgurl" alt=""> -->
        <!-- 绑定动态的类名 -->
        <p :class="actived">动态样式</p>
        <button @click="changeColor">修改颜色</button>
        <!-- 同时绑定多个动态属性 -->
        <p :style="attrsObj">多个属性设置样式</p>
        <p v-bind="attrsObj1">多个属性</p>
    </div>
</body>

</html>
<script>
    // v-bind: 
    // 定义: 用来给标签绑定动态属性
    // 语法: v-bind:属性名= '变量'  简写方式 :属性='变量'
    const app = Vue.createApp({
        data() {
            return {
                msg: '及时雨-宋江',
                idnum: 100,
                flag: true,
                imgurl: 'https://img2.baidu.com/it/u=1640220354,1827264725&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=750',
                actived: 'on',
                attrsObj: {
                    background: "green",
                    fontSize: "30px"
                },
                attrsObj1: {
                    class: 'on',
                    id: '100',
                    abc: '哈哈哈'
                }
            }
        },
        methods: {
            changeColor() {
                if (this.actived == 'on') {
                    this.actived = ''
                } else {
                    this.actived = 'on'
                }
            }
        }
    }).mount('#app')

</script>